home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 436_01 / inhelp.c < prev    next >
Text File  |  1994-10-07  |  4KB  |  106 lines

  1. /*************************************************************************
  2.     INHELP.C
  3.  
  4.     INCON demo program help window.
  5.  
  6.     INCON source files and the object and library files created from
  7.     them are:
  8.         Copyright (c) 1993-94, Richard Zigler.
  9.     You may freely distribute unmodified source, object, and library
  10.     files, and incorporate them into your own non-commercial software,
  11.     provided that this paragraph and the program name and copyright
  12.     strings defined in INCON.C are included in all copies.
  13. *************************************************************************/
  14.  
  15. #include <bios.h>
  16. #include <conio.h>
  17. #include <dos.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include "indefs.h"
  21. #include "indecl.h"
  22. #include "addattr.h"
  23.  
  24. #define HELP_WIN            11,3,69,23        /* help window coordinates            */
  25.  
  26. static char                 HelpStr[] =
  27. {
  28. "╔══════════════╤══════════════════════╤═══════════════════╗"
  29. "║  INCON Keys  │   Template Fields    │   Other Fields    ║"
  30. "╠═╤═╤══════════╪══════════════════════╪═══════════════════╣"
  31. "║ │~C~│   Home   │ First Input Slot     │ Start of Field    ║"
  32. "║ │~U~│   End    │ Last Input Slot      │ End of Field      ║"
  33. "║ │~R~│   Left   │ Previous Input Slot  │ Character Left    ║"
  34. "║ │~S~│   Right  │ Next Input Slot      │ Character Right   ║"
  35. "║ │~O~│  ^Left   │ Input Group Left     │ Word Left         ║"
  36. "║ │~R~│  ^Right  │ Input Group Right    │ Word Right        ║"
  37. "╟─┼─┼──────────┼──────────────────────┼───────────────────╢"
  38. "║ │ │  ^Home   │ Clear Slots to First │ Clear to Start    ║"
  39. "║ │ │  ^End    │ Clear Slots to Last  │ Clear to End      ║"
  40. "║ │ │  ^L      │ Delete Group Left    │ Delete Word Left  ║"
  41. "║ │~E~│  ^R      │ Delete Group Right   │ Delete Word Right ║"
  42. "║ │~D~│   Del    │ Delete at Cursor     │ Delete at Cursor  ║"
  43. "║ │~I~│   BS     │ Delete Slot Left     │ Delete Left       ║"
  44. "║ │~T~│   Esc    │ Clear All Slots      │ Clear Input Field ║"
  45. "║ │ │   Num +  │ Special Exit         │ Special Exit      ║"
  46. "║ │ │   Num -  │ Special Exit         │ Special Exit      ║"
  47. "║ │ │   Enter  │ Terminate Input      │ Terminate Input   ║"
  48. "╚═╧═╧══════════╧══════════════════════╧═══════════════════╝"
  49. };
  50.  
  51. #define NUM_ATTRS            20
  52.  
  53. static char                    AttrList[NUM_ATTRS];
  54.  
  55. /************************************************************************/
  56. /* Display help screen.  To initialize AttrList, pass a negative            */
  57. /* value in Attr (set the high bit); thereafter, pass normal attribute.    */
  58.  
  59. int pascal InHelp( register int Attr )
  60.     {
  61.     int        rtn = 0;
  62.  
  63.     if ( Attr < 0 )                            /* init help screen attributes    */
  64.         {
  65.         int i;
  66.         int high_attr = Attr ^ 0x0F;        /* complement fgnd for highlight    */
  67.  
  68.         /* if high_attr is invisible, toggle intensity bit                        */
  69.  
  70.         if ( ((high_attr & 0x70) >> 4) == (high_attr & 0x0F) )
  71.             high_attr ^= 0x08;
  72.         for ( i = NUM_ATTRS - 1 ; i >= 0 ; i-- )
  73.             AttrList[i] = i & 1 ? Attr : high_attr ;
  74.       }
  75.     else
  76.         {
  77.         char    *    save_scr = NULL;
  78.         char    *    help_scr = NULL;
  79.         if (
  80.             (save_scr = malloc( sizeof(HelpStr) * 2 )) == NULL
  81.             ||
  82.             (help_scr = malloc( sizeof(HelpStr) * 2 )) == NULL
  83.             )
  84.             --rtn;
  85.         else
  86.             {
  87.             Cursor( OFF );
  88.             gettext( HELP_WIN, save_scr );
  89.             AddAttr( help_scr, HelpStr, AttrList, NUM_ATTRS, Attr, '~' );
  90.             puttext( HELP_WIN, help_scr );
  91.             while ( !KEYREADY )                            /* wait for keypress        */
  92.                 ;
  93.             KEYREAD;                                            /*   and throw it away    */
  94.             puttext( HELP_WIN, save_scr );
  95.             Cursor( ON );
  96.             }
  97.       if ( help_scr )
  98.             free( help_scr );
  99.         if ( save_scr )
  100.             free( save_scr );
  101.         }
  102.     return( rtn );
  103.    }
  104.  
  105. /**** EOF:  INHELP.C ****/
  106.